<template>
    <div id="qrcode" style="width: 200px;height: 200px"></div>
</template>

<script>
export default {
    name: 'Message',
    data() {
        return {
            qrcode: null
        }
    },
    props: ['proParm'],
    mounted() {
        this.qrcode = new QRCode(document.getElementById("qrcode"), {
            width: 200,
            height: 200
        });
        this.init();
    },
    methods: {
        init(result) {
            result = result || this.proParm;
            if (typeof (result) !== 'string') {
                let objCopy = Object.assign({}, result);
                delete objCopy.confirmations;
                delete objCopy.satoshis;
                delete objCopy.height;
                // 复制原来的值
                if (objCopy.dealType === 1) {
                    objCopy['index'] = objCopy.vout.toString();
                }
                objCopy.amount = objCopy.amount.toString();
                delete objCopy.vout;
                objCopy = JSON.stringify(objCopy);
                this.qrcode.makeCode(objCopy);
            } else {
                this.qrcode.makeCode(result);
            }
        }
    }
}
</script>

<style scoped>

</style>
